<template>
  <div>
    <h5>我的登陆状态：{{user?'已登陆':'未登录'}}</h5>
    <h5>我的name: {{user.user.username}}</h5>
    <h5>我的照片：<img :src="user.user.avatar" alt="user.name"></h5>
    <button type="button">logout</button>
  </div>
</template>

<script>
  export default {
    name: "my",
    data(){
      return{
        logining:false,
      }
    },
    methods:{
      logout(){
        sessionStorage.removeItem('user')
        this.$router.push('/login')
      }
    },
    computed:{
      user(){
        return this.$store.state.user
      }
    },
    mounted(){
      let user = sessionStorage.getItem('user')
      if(user){
        user = JSON.parse(user);
        this.username = user.name
      }
    }
  }
</script>

<style scoped>

</style>
